<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="UTF-8">
        <title>系统日志信息</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport"
              content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
        <link rel="stylesheet" th:href="${urls.getForLookupPath('/css/font.css')}">
        <link rel="stylesheet" th:href="${urls.getForLookupPath('/css/xadmin.css')}">
        <script th:src="${urls.getForLookupPath('/lib/layui/layui.js')}" charset="utf-8"></script>
        <script type="text/javascript" th:src="${urls.getForLookupPath('/js/xadmin.js')}"></script>
    </head>
    <body class="systemlog">
        <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
               onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div shiro:hasPermission="S" class="layui-card-body ">
                            <div class="layui-inline layui-show-xs-block">
                                <input id="username" type="text" name="username" placeholder="请输入查询用户"
                                       autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" onclick="logUsernameSearch()">
                                    <i class="layui-icon">&#xe615;</i></button>
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" id="searchtime" name="searchtime" type="text"
                                       placeholder="请选择查询时间" autocomplete="off">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" onclick="logTimeSearch()">
                                    <i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </div>
                        <div class="layui-card-header">
                            <button class="layui-btn layui-btn-normal" onclick="backtoLogList()">
                                <i class="layui-icon">&#xe62d;</i>系统日志列表
                            </button>
                        </div>
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form">
                                <thead>
                                <tr>
                                    <th>日志编号</th>
                                    <th>操作用户名</th>
                                    <th>操作方法</th>
                                    <th>操作具体描述</th>
                                    <th>操作时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="systemlog:${page.list}">
                                    <td th:text="${systemlog.id}"></td>
                                    <td th:text="${systemlog.username}"></td>
                                    <td th:text="${systemlog.method}"></td>
                                    <td th:text="${systemlog.describes}"></td>
                                    <td th:text="${#dates.format(systemlog.time, 'yyyy-MM-dd HH:mm:ss')}"></td>
                                </tr>

                                </tbody>
                            </table>
                        </div>
                        <div class="layui-card-body ">
                            <div class="page">
                                <!--当前页数小于等于1时，上一页还是显示第一页的信息-->
                                <div th:if="${page.pageNum} le 1">
                                    <a class="prev" th:href="@{/adminmanage/systemlogList(pn=1)}">&lt;&lt;</a>
                                    <a class="num" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum})}">上一页</a>
                                    <span class="current" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum})}"
                                          th:text="${page.pageNum}"></span>
                                    <a class="num" th:if="${page.pageNum} lt ${page.pages}"
                                       th:href="@{/adminmanage/systemlogList(pn=${page.pageNum+1})}">下一页</a>
                                    <a class="next" th:href="@{/adminmanage/systemlogList(pn=${page.pages})}">&gt;&gt;</a>
                                </div>
                                <!--当前页数大于等于最后一页时，点击下一页还是显示最尾页页的信息-->
                                <div th:if="${page.pageNum} != 1 and ${page.pageNum} ge ${page.pages}">
                                    <a class="prev" th:href="@{/adminmanage/systemlogList(pn=1)}">&lt;&lt;</a>
                                    <a class="num" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum-1})}">上一页</a>
                                    <span class="current" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum})}"
                                          th:text="${page.pageNum}"></span>
                                    <a class="num" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum})}">下一页</a>
                                    <a class="next" th:href="@{/adminmanage/systemlogList(pn=${page.pages})}">&gt;&gt;</a>
                                </div>
                                <!--非首尾页-->
                                <div th:if="${page.pageNum} gt 1 and ${page.pageNum} lt ${page.pages}">
                                    <a class="prev" th:href="@{/adminmanage/systemlogList(pn=1)}">&lt;&lt;</a>
                                    <a class="num" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum-1})}">上一页</a>
                                    <span class="current" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum})}"
                                          th:text="${page.pageNum}"></span>
                                    <a class="num" th:href="@{/adminmanage/systemlogList(pn=${page.pageNum+1})}">下一页</a>
                                    <a class="next" th:href="@{/adminmanage/systemlogList(pn=${page.pages})}">&gt;&gt;</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script>
        var option, time;
        layui.use(['laydate', 'form'], function () {
            var laydate = layui.laydate;

            laydate.render({
                elem: '#searchtime'
                , showBottom: false
                , trigger: 'click'
                , done: function (value) {
                    time = value;
                }
            });
        });

        /**
         * 根据操作用户查找日志记录
         */
        function logUsernameSearch() {
            var username = document.getElementById('username').value;
            if (username.length === 0) {
                layer.msg('请输入待查询用户！', {icon: 5, time: 1000});
            } else {
                window.location.href = "/adminmanage/usernameSearchLog/" + username;
            }
        }

        /**
         * 根据日期查询日志记录
         */
        function logTimeSearch() {
            console.log(time);
            if (typeof(time) === "undefined"){  //判断日期是否为空
                layer.msg('请选择查询时间！', {icon: 5, time: 1000});
            } else {
                window.location.href = "/adminmanage/timeSearchLog/" + time;
            }
        }

        function backtoLogList() {
            window.location.href = "/adminmanage/systemlogList";
        }
    </script>
</html>